#include<bits/stdc++.h>
using namespace std;
int n,m;
int vis[40010];
int ans[501][501],a[501][501];
bool check(int i,int j){
    if(i<=0||i>n||j<=0||j>m){
        return 0;
    }
    return 1;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
            a[i][j]+=10000;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int x,y;
            x=i-1,y=j-1;
            memset(vis,0,sizeof(vis));
            int cnt1=1;
            vis[a[i][j]]=1;
            while(check(x,y)){
                if(vis[a[x][y]]==0){
                    vis[a[x][y]]++;
                    cnt1++;
                }
                x--,y--;
            }

            x=i+1,y=j+1;
            memset(vis,0,sizeof(vis));
            int cnt2=0;
            while(check(x,y)){
                if(vis[a[x][y]]==0){
                    vis[a[x][y]]++;
                    cnt2++;
                }
                x++,y++;
            }
            ans[i][j]=abs(cnt1-cnt2);
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}
